package Offer2018;

/**
 * 反转链表
 * Created by 雷文康 on 2018/3/4.
 */
public class Test16 {

    public static ListNode reverseListNode(ListNode head) {
        if (head == null) {
            return null;
        }
        ListNode before = head;
        ListNode p = head.next;
        head.next = null;
        while (p != null) {
            ListNode after = p.next;
            p.next = before;

            before = p;
            p = after;
        }
        return before;

    }
}
